#include <iostream>
#include <string>
#include <unordered_map>

bool is_prime(int num) {
    if (num < 2) {
        return false;
    }
    for (int i = 2; i * i <= num; i++) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

void closest_prime(std::string words[]) {
    std::unordered_map<std::string, int> numbers = {
        {"zero", 0}, {"one", 1}, {"two", 2}, {"three", 3}, {"four", 4}, 
        {"five", 5}, {"six", 6}, {"seven", 7}, {"eight", 8}, {"nine", 9}
    };

    std::string num_str = "";
    for (int i = 0; i < 3; i++) {
        if (numbers.find(words[i]) != numbers.end()) {
            num_str += std::to_string(numbers[words[i]]);
        } else {
            std::cout << "Wrong input" << std::endl;
            return;
        }
    }

    int num = std::stoi(num_str);

    if (num_str.length() != 3) {
        std::cout << "Wrong input" << std::endl;
        return;
    }

    while (!is_prime(num)) {
        num++;
    }

    std::cout << num << std::endl;
}

int main() {
    std::string words[3];
    std::cin >> words[0] >> words[1] >> words[2];
    closest_prime(words);
    return 0;
}




